// localLifePackage/codeApply/codeApply.js
var common = require("../../../common/common.js").common;

Page({
    /**
   * 页面的初始数据
   */
    data: {
        name: ""
    },
    /**
   * 生命周期函数--监听页面加载
   */
    onLoad: function(options) {
        this.setData({
            name: options.name
        });
        this.getBase();
    },
    /**
   * 生命周期函数--监听页面初次渲染完成
   */
    onReady: function() {},
    /**
   * 生命周期函数--监听页面显示
   */
    onShow: function() {},
    /**
   * 生命周期函数--监听页面隐藏
   */
    onHide: function() {},
    /**
   * 生命周期函数--监听页面卸载
   */
    onUnload: function() {},
    /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
    onPullDownRefresh: function() {},
    /**
   * 页面上拉触底事件的处理函数
   */
    onReachBottom: function() {},
    /**
   * 用户点击右上角分享
   */
    onShareAppMessage: function() {},
    getBase: function() {
        var that = this;
        common.request({
            endpoint: "set/app_base",
            method: "get",
            data: {},
            success: res => {
                wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: res.extra.color_main
                });
                var componentStyle = that.data.componentStyle;
                that.setData({
                    componentStyle: {
                        ...componentStyle,
                        color_minor: !res.extra.color_main ? "#FE513B" : res.extra.color_main,
                        color_minor: !res.extra.color_minor ? "#FE513B" : res.extra.color_minor
                    },
                    color_main: res.extra.color_main,
                    color_minor: res.extra.color_minor,
                    rp_name: res.extra.rp_name,
                    luck_img: res.extra.luck_img,
                    little_title: res.extra.title
                });
            }
        });
    },
    toWriteOff: function() {
        wx.navigateTo({
            url: "/localLifePackage/pages/writeOff/writeOff"
        });
    },
    toGoodsOff: function() {
        wx.showModal({
            title: "提示",
            content: "暂未开放该功能"
        });
    }
});